import {instance, addChannelParams} from './instance';
import {userSchema} from '@/types/schemas/user';
import {ResponseData} from "@/types/utils";
import {LoginResponse, User} from "@/types/user";
import {ChartData} from "@/types/chart";

export function fetchLogin<D>(body: D) {
    return instance.post('agent/login', {json: addChannelParams(body)}).json<ResponseData<LoginResponse>>();
}

//获取用户信息
export function fetchUser() {
    return instance.post('agent/detail', {json: addChannelParams()}).json<ResponseData<User>>();
}

// 获取首页图表数据
export function fetchIndexChart<D>(data: D) {
    return instance.post('SecondAccount/getTrendChart', {json: addChannelParams(data)}).json<ResponseData<ChartData>>();
}

// 切换平台账户
export function checkAccount<D>(data: D) {
    return instance.post('agent/checkAccount', {json: addChannelParams(data)}).json<ResponseData<User>>();
}